# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=atop
pkgver=2.9.0
pkgrel=2
pkgdesc="Resource-specific view of processes"
url="https://www.atoptool.nl/"
arch="all"
license="GPL-2.0-or-later"
makedepends="zlib-dev ncurses-dev linux-headers"
subpackages="$pkgname-doc $pkgname-openrc"
source="$pkgname-$pkgver.tgz::https://www.atoptool.nl/download/atop-$pkgver.tar.gz
	atop-daily-bb.patch
	atop-include-macros.patch
	make-cron-background.patch
	format-sec.patch
	gcc13.patch
	atop.initd
"
options="!check"

prepare() {
	default_prepare

	sed -i -e '/DEFPATH/d' Makefile

	cp "$srcdir"/atop.initd atop.init
	chmod a+rx atop.init
}

build() {
	make
}

package() {
	make DESTDIR="$pkgdir" \
		INIPATH=/etc/init.d \
		SCRPATH=/etc/periodic/daily \
		sysvinstall
	rm -fr "$pkgdir"/etc/cron.d
	mv "$pkgdir"/etc/periodic/daily/atop.daily \
		"$pkgdir"/etc/periodic/daily/atop
}

sha512sums="
a79eb142b16c32d43ee3220bdaf3a1b3861b713bfd86f4e7d2241cadf84f5d09a054289442e4d91499852069735b8cd16760c6fc46f65639fe429ceb68534544  atop-2.9.0.tgz
664225450074962aac0e13484c9b2feaf08620bbe1e0f9c5dc1b02f1ecd315224cd04df53134f2d107210fc9223a64d8885ae70d33d0663c2335fa6d46f6ddfd  atop-daily-bb.patch
f30c9e6051332af8c8cafcd881f89a0e2d2a8e1d84eee8ac0c8c6b58f3ae3431fcf9c40dea6d03e271f8969802de449d33b4323c13045bdb38a539732c81a8b6  atop-include-macros.patch
e563894eceadf63ff153714829218b8f78dd21a129b90817960bdb4452768f41ed884dc9967f94b979e42f04d6434fcbd423bcf1651976a5ad60c34b206ce7e9  make-cron-background.patch
808ea5991fdacd547124008ab47906461d27dbab4955de71ead1bc080796c8aef05cc16884456cf8c4b65ce205423f5a971b0d422e01286390ad3dc5b3cfe461  format-sec.patch
5727287f891ab9487a33b13754cd02468725aad5daef9e46aac507eef9871e8f9cfbfa546f47dbe25ee25e0924b773e5966f0d82a39947d0b8792e08260f1a7b  gcc13.patch
efbf36d933a8be90ebf2fd54a188cd1c9bc9b8d87755625aba85831a83f3a087dbe6e953f7ce36b38d9909b9ab747e0e9186ad0e85382d5b4e8690c9cfdc0d40  atop.initd
"
